package com.athena.view 
{
	import com.athena.ui.confirm;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	/**
	 * ...
	 * @author ...
	 */
	public class ConfirmPopup extends confirm
	{
		public static var POPUPNAME : String = "com.athena.ui.ConfirmPopup";
		public static var ACCEPT : String = "accept";
		public function ConfirmPopup(str : String) 
		{
			var glow:GlowFilter = new GlowFilter();
			glow.color = 0x000000;
			glow.alpha = 0.5;
			glow.blurX = 10;
			glow.blurY = 10;
			glow.quality = BitmapFilterQuality.MEDIUM;

			filters=[glow];
			
			var _w : Number = width; var _h : Number = height;
			var rectangle:Shape = new Shape();
			rectangle.graphics.beginFill(0x000000, 1);
			rectangle.graphics.drawRect((_w - Main.getInstance().config.demension.x) / 2, (_h - Main.getInstance().config.demension.y) / 2, Main.getInstance().config.demension.x, Main.getInstance().config.demension.x);
			rectangle.alpha = 0;
			rectangle.graphics.endFill();
			addChild(rectangle);
			setChildIndex(rectangle, 0);
			
			this.x = (Main.getInstance().config.demension.x - _w) / 2;
			this.y = (Main.getInstance().config.demension.y - _h) / 2;
			
			msg_txt.text = str;
			ok_btn.addEventListener(MouseEvent.CLICK, accept);
			cancel_btn.addEventListener(MouseEvent.CLICK, cancel);
			this.name = POPUPNAME;
		}
		
		private function accept(e  :MouseEvent)  :void {
			dispatchEvent(new Event(ACCEPT));
			cancel(null);
		}
		private function cancel(e : MouseEvent)  :void {
			ok_btn.removeEventListener(MouseEvent.CLICK, accept);
			cancel_btn.removeEventListener(MouseEvent.CLICK, cancel);
			this.parent.removeChild(this);
		}
		
	}

}